extends ColorRect

var mouse_enter=0
# Called when the node enters the scene tree for the first time.
var node_name
func _ready():
	
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	if mouse_enter==1:
		if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
			print("mouse_click")
			if get_child_count()==0:
				pass # Replace with function body.
			else:
				var grid = get_child(0)
				var gezi_index=get_name().erase(0,9).to_int()
				print(gezi_index)
				use_prop(gezi_index)
				#判断子节点的类型做出先对应的动作
				remove_child(grid)
	
func _on_mouse_entered():
	print("mouse_entered")
	print(get_name().erase(0,9).to_int())
	mouse_enter=1
	pass

func _on_mouse_exited():
	print("mouse_exited")
	mouse_enter=0
	pass # Replace with function body.

func use_prop(index):
	if Event.rucksack_prop[index-1]==3:
		Event.rucksack_prop[index-1]=0
		Event.player_use_bow.emit()
		pass
